package com.struggle.myrabbitmq.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import lombok.SneakyThrows;

import java.io.IOException;

/**
 * @className ConnectionUtil
 * @Description rabbitMQ连接工具
 * @Author liuwj3
 * @Date 2019/9/18 0018 下午 9:11
 **/
public class ConnectionUtil {
    @SneakyThrows
    public static Connection getConnection() {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        factory.setPort(5672);

        factory.setVirtualHost("testhost");
        factory.setUsername("admin");
        factory.setPassword("123");

        return factory.newConnection();
    }
}
